//
//  SceneryCell.m
//  UIViewControllerTransitionDemo
//
//  Created by Guo Rui on 2017/7/4.
//  Copyright © 2017年 GR Harry. All rights reserved.
//

#import "SceneryCell.h"

@interface SceneryCell ()
@property (strong, nonatomic) UIImageView *pictureImageView;
@property (strong, nonatomic) UILabel *placeLabel;
@end

@implementation SceneryCell

#pragma mark - Life Cycle
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.contentView.backgroundColor = [UIColor whiteColor];
        [self setupViews];
    }
    return self;
}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    self.pictureImageView.frame = CGRectMake(10, 0, CGRectGetWidth(self.contentView.frame) - 2 * 10.f, CGRectGetHeight(self.contentView.frame) - 40.f);
    self.placeLabel.frame = CGRectMake(0, CGRectGetMaxY(self.pictureImageView.frame), CGRectGetWidth(self.contentView.frame), 40.f);
}

#pragma mark - Public
- (void)setPlace:(NSString *)placeName {
    self.placeLabel.text = placeName;
}

- (void)setPicture:(UIImage *)picture {
    self.pictureImageView.image = picture;
}

#pragma mark - Private
- (void)setupViews {
    self.pictureImageView = [[UIImageView alloc] init];
    self.pictureImageView.contentMode = UIViewContentModeScaleToFill;
    [self.contentView addSubview:self.pictureImageView];
    
    self.placeLabel = [[UILabel alloc] init];
    self.placeLabel.textColor = [UIColor blackColor];
    self.placeLabel.textAlignment = NSTextAlignmentCenter;
    self.placeLabel.font = [UIFont systemFontOfSize:16];
    [self.contentView addSubview:self.placeLabel];
}



@end
